package com.sicheng.metadata.se.exp.second;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.junit.Test;

import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @author zsc
 * @version 1.0
 * @date 2021/10/7 16:08
 */

@SuppressWarnings("all")
public class DayOfYear {
    public static void main(String[] args) throws ParseException {
        System.out.println("输入日期，格式是，例如：2013-12-3");
        Scanner sc = new Scanner(System.in);
        String str_date = sc.nextLine();
        showDate(str_date);
        sc.close();

    }

    private static void showDate(String str_date) throws ParseException {

        DateFormat dateFormat = DateFormat.getDateInstance();
        Date date = dateFormat.parse(str_date);

        Calendar c = Calendar.getInstance();

        c.setTime(date);

        int day = c.get(Calendar.DAY_OF_YEAR);

        int week = c.get(Calendar.DAY_OF_WEEK);

        System.out.println(str_date + "，是这一年中的第" + day + "天");
    }

    private static String getWeek(int week) {
        String[] weeks = {"", "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六",};
        return weeks[week];
    }

    @Test
    public void rmList() {
        List<Integer> list = Arrays.stream(new Integer[10]).collect(Collectors.toList());
        list.remove(7);
        list.forEach(System.out::println);

    }

    @Test
    public void set() {
        HashSet<String> set = new HashSet<>();

        set.add("Aaa");
        set.add("abB");
        set.add("aaA");
        set.add("BaA");
        set.add("aaA");
        set.forEach(System.out::println);
    }


    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    static class Employee {
        String id;
        String name;
    }

    @Test
    public void empTest() {
        HashMap<String, Employee> map = new HashMap<>();

        Employee sicheng = new Employee("2019222", "sicheng");
        Employee xuxiang = new Employee("2019220", "xuxiang");
        Employee jiahao = new Employee("2019221", "jiahao");

        map.put(sicheng.getId(), sicheng);
        map.put(xuxiang.getId(), xuxiang);
        map.put(jiahao.getId(), jiahao);

        map.forEach((k, v) -> System.out.println(k + ":" + v.name));
    }

    @Test
    public void listTest() {
        ArrayList<String> list = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            list.add(String.valueOf(i));
        }

        ListIterator<String> iterator = list.listIterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }

        long time = Timestamp.valueOf("2019-2-12 10:9:00").getTime();
        System.out.println(time);


    }

}
